<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="initial-scale=1.0,
                   maximum-scale=1.0">
    <title>进阶篇-devtools使用</title>
    <script src="../js/lib/vue.min.js"></script>
</head>
<body>
<div id="app">
    <!--简单加法实现，添加3个输入框，加数和被加数添加键盘恢复事件-->
    <input type="text" v-model="augend" @keyup="calculate">
    <span>+</span>
    <input type="text" v-model="addend" @keyup="calculate">
    <span>=</span>
    <input type="text" :value="sum" >
    <br>
    <br>
    <button @click="reset">清空数据</button>
</div>
<script>
    const app = new Vue({
        el:'#app',
        data:{
            augend:'',
            addend:'',
            sum:''
        },
        methods:{
            //计算结果
            calculate(){
                this.sum = Number(this.augend) + Number(this.addend);
            },
            reset(){
                this.augend='';
                this.addend='';
                this.sum='';
                this.$emit('reset');
            }
        }
    });
</script>
</body>
</html>